package game
{
	import com.yzy.models.SetLibs;
	import com.yzy.tool.Utils;
	
	import flash.geom.Point;
	import flash.system.System;
	
	import control.Control;
	
	import effect.Effect;
	
	import game.bejeweled.BejeweledBlock;
	import game.monster.MonstersBlock;
	import game.ui.GameUI;
	import game.ui.NumberMC;
	
	import starling.display.Image;
	import starling.display.Sprite;
	import starling.events.Event;
	import starling.textures.Texture;
	
	public class Game extends Sprite
	{
		
		
		public function Game()
		{
			super();
			this.addEventListener(Event.ADDED_TO_STAGE,onAdded);
		}
		
		private function onAdded(e:starling.events.Event):void
		{
			var profileXml:XML=new XML(String(SetLibs.getLibsData("Profile")));
			//宝石层
			var bjBlock:BejeweledBlock=BejeweledBlock.instant;
			bjBlock.init(profileXml.Resources.bejeweled);
			//怪物层
			var msBlock:MonstersBlock=MonstersBlock.instant;
			msBlock.init(profileXml.Resources.monsters)
			//背景
			var bgimage:Image=new Image(Texture.fromBitmapData(SetLibs.getBitmapData("game_bg")));
			//ui层
			var gameui:GameUI=GameUI.instant;
			gameui.init();
			
			this.addChild(bgimage);
			this.addChild(msBlock);
			this.addChild(bjBlock);
			this.addChild(Effect.instant);
			this.addChild(gameui);
			
			Control.instant.initGameCtrl();
			
			///////////////////////
			SetLibs.removeLibs();
			SetLibs.removeAllElement(SetLibs._BitmapDs);
			Utils.gc();
			System.gc();
		}
	}
}